package interfaces

import (
	"github.com/aws/constructs-go/constructs/v10"
	// "github.com/aws/jsii-runtime-go"

	"github.com/cdktf/cdktf-provider-aws-go/aws/v17/securitygroup"
	"github.com/cdktf/cdktf-provider-aws-go/aws/v17/subnet"
	"github.com/cdktf/cdktf-provider-aws-go/aws/v17/vpc"
)

// NetworkConfig 网络配置
type NetworkConfig struct {
	VpcCidrBlock     string
	SubnetCidrBlock  string
	AvailabilityZone string
	Region           string
}

// VPCConfig VPC 配置
type VPCConfig struct {
	Name      string
	CidrBlock string
	Region    string
	Tags      map[string]string
}

// SubnetConfig 子网配置
type SubnetConfig struct {
	Name                string
	CidrBlock           string
	AvailabilityZone    string
	VpcID               string
	MapPublicIPOnLaunch bool
	Tags                map[string]string
}

// SecurityGroupConfig 安全组配置
type SecurityGroupConfig struct {
	Name         string
	Description  string
	VpcID        string
	IngressRules []SecurityGroupRule
	EgressRules  []SecurityGroupRule
	Tags         map[string]string
}

// SecurityGroupRule 安全组规则
type SecurityGroupRule struct {
	Description string
	FromPort    int
	ToPort      int
	Protocol    string
	CidrBlocks  []string
}

// EC2Config EC2 配置
// type EC2Config struct {
// 	Name              string
// 	AmiID             string
// 	InstanceType      string
// 	KeyName           string
// 	SubnetID          string
// 	SecurityGroupIDs  []*string
// 	UserData          string
// 	Tags              map[string]string
// 	AssociatePublicIP bool
// }

// VPCCreator VPC 创建接口
type VPCCreator interface {
	CreateVPC(scope constructs.Construct, id string, config *VPCConfig) (*vpc.Vpc, error)
	GetVPCByID(scope constructs.Construct, vpcID string) (*vpc.Vpc, error)
	ListVPCs() map[string]*vpc.Vpc
}

// SubnetCreator 子网创建接口
type SubnetCreator interface {
	CreateSubnet(scope constructs.Construct, id string, config *SubnetConfig) (*subnet.Subnet, error)
	GetSubnetByID(scope constructs.Construct, subnetID string) (*subnet.Subnet, error)
	ListSubnets() map[string]*subnet.Subnet
	GetSubnetsByVPC(vpcID string) map[string]*subnet.Subnet
}

// SecurityGroupCreator 安全组创建接口
type SecurityGroupCreator interface {
	CreateSecurityGroup(scope constructs.Construct, id string, config *SecurityGroupConfig) (*securitygroup.SecurityGroup, error)
	GetSecurityGroupByID(scope constructs.Construct, sgID string) (*securitygroup.SecurityGroup, error)
	ListSecurityGroups() map[string]*securitygroup.SecurityGroup
	GetSecurityGroupsByVPC(vpcID string) map[string]*securitygroup.SecurityGroup
}

// EC2Creator EC2 创建接口
// type EC2Creator interface {
// 	CreateEC2Instance(scope constructs.Construct, id string, config *EC2Config) (*instance.Instance, error)
// 	GetInstanceByID(scope constructs.Construct, instanceID string) (*instance.Instance, error)
// 	ListInstances() map[string]*instance.Instance
// 	GetInstancesBySubnet(subnetID string) map[string]*instance.Instance
// }
